import pymysql


# 建立数据库连接
def connection():
    conn = pymysql.connect(
        host="47.100.4.195",
        port=3306,
        user='root',
        password='danshashouA110!',
        database='ry3',
        charset='utf8')
    return conn


# 数据入库
def saveSql(sql):
    conn = connection()
    # 获取操作数据库的游标
    cur = conn.cursor()
    try:
        # 执行sql语句
        cur.execute(sql)
        conn.commit()
        conn.close()
    except Exception as e:
        print(e)
